Change in openvpn[master]: Only schedule_exit() once
A message that is not in the archive (sent off-list or not yet received): gerrit.1713783920000.I9457f005f4ba970502e6b667d9dc4299a588d661@...2715...
Attention is currently required from: flichtenheld, plaisthos.
Hello plaisthos, flichtenheld,
I'd like you to do a code review.
Please visit
http://gerrit.openvpn.net/c/openvpn/+/555?usp=email
to review the following change.
Change subject: Only schedule_exit() once
......................................................................
Only schedule_exit() once
If an exit has already been scheduled we should not schedule it again. Otherwise, the exit signal is never emitted if the peer reschedules the exit before the timeout occurs.
---
M src/openvpn/forward.c
1 file changed, 5 insertions(+), 0 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/55/555/1
src/openvpn/forward.c +5 -0
@@ -519,6 +519,11 @@void schedule_exit (struct context *c,const int n_seconds,const int signal) { +/* don't reschedule if already scheduled; we drop the new signal, but it +* only ever seems to be SIGTERM anyway. */ +if (event_timeout_defined (&c->c2.scheduled_exit)) { +return ; + }tls_set_single_session (c->c2.tls_multi);update_time ();reset_coarse_timers (c);
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/555?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I9457f005f4ba970502e6b667d9dc4299a588d661
Gerrit-Change-Number: 555
Gerrit-PatchSet: 1
Gerrit-Owner: reynir <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-MessageType: newchange
Attention is currently required from: flichtenheld, plaisthos.
reynir has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/555?usp=email )
Change subject: Only schedule_exit() once
......................................................................
Patch Set 1: Code-Review+2
(1 comment)
File src/openvpn/forward.c:
http://gerrit.openvpn.net/c/openvpn/+/555/comment/b5a7a10b_17482a9e :
PS1, Line 529: reset_coarse_timers(c);
I am not sure what the above three function calls do and if we should still call them.
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/555?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I9457f005f4ba970502e6b667d9dc4299a588d661
Gerrit-Change-Number: 555
Gerrit-PatchSet: 1
Gerrit-Owner: reynir <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-Reviewer: reynir <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Mon, 22 Apr 2024 11:14:15 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
Attention is currently required from: flichtenheld, plaisthos.
reynir has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/555?usp=email )
Change subject: Only schedule_exit() once
......................................................................
Patch Set 1: Code-Review-1
(2 comments)
File src/openvpn/forward.c:
http://gerrit.openvpn.net/c/openvpn/+/555/comment/3395ca91_15f2e5ca :
PS1, Line 523: * only ever seems to be SIGTERM anyway. */
I also considered dropping the signal argument as it is currently always SIGTERM at all call sites.
http://gerrit.openvpn.net/c/openvpn/+/555/comment/f2f84020_796d7125 :
PS1, Line 530: event_timeout_init(&c->c2.scheduled_exit, n_seconds, now);
I have only now thought of it: what if the new n_seconds is sooner than the already scheduled exit?! I suspect n_seconds is always 5, though.
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/555?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I9457f005f4ba970502e6b667d9dc4299a588d661
Gerrit-Change-Number: 555
Gerrit-PatchSet: 1
Gerrit-Owner: reynir <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-Reviewer: reynir <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Mon, 22 Apr 2024 11:19:41 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
Attention is currently required from: plaisthos, reynir.
flichtenheld has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/555?usp=email )
Change subject: Only schedule_exit() once
......................................................................
Patch Set 1:
(2 comments)
File src/openvpn/forward.c:
http://gerrit.openvpn.net/c/openvpn/+/555/comment/832e9f3f_055cb4bc :
PS1, Line 525: return;
You might want to consider changing the function to return a boolean to indicate whether it did anything. send_auth_failure already does the same check and could just use this one instead. And the other callers might also benefit from not doing other actions if exit is already scheduled.
http://gerrit.openvpn.net/c/openvpn/+/555/comment/73f172e8_be13b424 :
PS1, Line 530: event_timeout_init(&c->c2.scheduled_exit, n_seconds, now);
Quoted 1 line
I have only now thought of it: what if the new
n_secondsis sooner than the already scheduled exit […]
It is always c->options.scheduled_exit_interval which is always 5 at the moment.
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/555?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I9457f005f4ba970502e6b667d9dc4299a588d661
Gerrit-Change-Number: 555
Gerrit-PatchSet: 1
Gerrit-Owner: reynir <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-Reviewer: reynir <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: reynir <[email protected]...>
Gerrit-Comment-Date: Mon, 22 Apr 2024 11:46:20 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: reynir <[email protected]...>
Gerrit-MessageType: comment
Attention is currently required from: plaisthos, reynir.
Hello flichtenheld, plaisthos,
I'd like you to reexamine a change. Please visit
http://gerrit.openvpn.net/c/openvpn/+/555?usp=email
to look at the new patch set (#2).
The following approvals got outdated and were removed:
Code-Review-1 by reynir
Change subject: Only schedule_exit() once
......................................................................
Only schedule_exit() once
If an exit has already been scheduled we should not schedule it again. Otherwise, the exit signal is never emitted if the peer reschedules the exit before the timeout occurs.
schedule_exit() now only takes the context as argument. The signal is hard coded to SIGTERM, and the interval is read directly from the context options.
Furthermore, schedule_exit() now returns a bool signifying whether an exit was scheduled; false if exit is already scheduled. The call sites are updated accordingly. A notable difference is that management is only notified *once* when an exit is scheduled - we no longer notify management on redundant exit.
---
M src/openvpn/forward.c
M src/openvpn/forward.h
M src/openvpn/push.c
3 files changed, 16 insertions(+), 11 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/55/555/2
src/openvpn/forward.c +10 -4
@@ -514,17 +514,23 @@ }/* -* Schedule a signal n_seconds from now. +* Schedule a SIGTERM signal c->options.scheduled_exit_interval seconds from now. */ -void -schedule_exit (struct context *c,const int n_seconds,const int signal) +bool +schedule_exit (struct context *c) { +const int n_seconds = c->options.scheduled_exit_interval; +/* don't reschedule if already scheduled. */ +if (event_timeout_defined (&c->c2.scheduled_exit)) { +return false; + }tls_set_single_session (c->c2.tls_multi);update_time ();reset_coarse_timers (c);event_timeout_init (&c->c2.scheduled_exit, n_seconds, now); - c->c2.scheduled_exit_signal = signal; + c->c2.scheduled_exit_signal =SIGTERM ;msg (D_SCHED_EXIT ,"Delayed exit in %d seconds" , n_seconds); +return true; }/*
src/openvpn/forward.h +1 -1
@@ -303,7 +303,7 @@void process_ip_header (struct context *c,unsigned int flags,struct buffer *buf); -void schedule_exit (struct context *c,const int n_seconds,const int signal); +bool schedule_exit (struct context *c);static inline struct link_socket_info *get_link_socket_info (struct context *c)
src/openvpn/push.c +5 -6
@@ -191,6 +191,7 @@ receive_exit_message(struct context *c) {dmsg (D_STREAM_ERRORS ,"CC-EEN exit message received by peer" ); +bool notify_management = true;/* With control channel exit notification, we want to give the session * enough time to handle retransmits and acknowledgment, so that eventual * retries from the client to resend the exit or ACKs will not trigger
@@ -204,14 +205,14 @@* */ if (c->options.mode ==MODE_SERVER ) { -schedule_exit (c, c->options.scheduled_exit_interval,SIGTERM ); + notify_management =schedule_exit (c); }else {register_signal (c->sig,SIGUSR1 ,"remote-exit" ); }#ifdef ENABLE_MANAGEMENT -if (management) +if (management && notify_management) {management_notify (management,"info" ,"remote-exit" ,"EXIT" ); }
@@ -391,7 +392,7 @@void send_auth_failed (struct context *c,const char *client_reason) { -if (event_timeout_defined (&c->c2.scheduled_exit)) +if (!schedule_exit (c)) {msg (D_TLS_DEBUG ,"exit already scheduled for context" );return ;
@@ -401,8 +402,6 @@static const char auth_failed[] ="AUTH_FAILED" ;size_t len; -schedule_exit (c, c->options.scheduled_exit_interval,SIGTERM ); - len = (client_reason ?strlen (client_reason)+1 :0 ) +sizeof (auth_failed);if (len >PUSH_BUNDLE_SIZE ) {
@@ -492,7 +491,7 @@void send_restart (struct context *c,const char *kill_msg) { -schedule_exit (c, c->options.scheduled_exit_interval,SIGTERM ); +schedule_exit (c);send_control_channel_string (c, kill_msg ? kill_msg :"RESTART" ,D_PUSH ); }
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/555?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I9457f005f4ba970502e6b667d9dc4299a588d661
Gerrit-Change-Number: 555
Gerrit-PatchSet: 2
Gerrit-Owner: reynir <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-Reviewer: reynir <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: reynir <[email protected]...>
Gerrit-MessageType: newpatchset
Attention is currently required from: plaisthos, reynir.
flichtenheld has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/555?usp=email )
Change subject: Only schedule_exit() once
......................................................................
Patch Set 2: Code-Review+2
(3 comments)
File src/openvpn/forward.c:
http://gerrit.openvpn.net/c/openvpn/+/555/comment/090e8b75_da780d6c :
PS1, Line 523: * only ever seems to be SIGTERM anyway. */
Quoted 1 line
I also considered dropping the
signalargument as it is currently alwaysSIGTERMat all call sit […]
Done
http://gerrit.openvpn.net/c/openvpn/+/555/comment/01a64bab_9f4236b8 :
PS1, Line 525: return;
Quoted 1 line
You might want to consider changing the function to return a boolean to indicate whether it did anyt […]
Done
http://gerrit.openvpn.net/c/openvpn/+/555/comment/123d7f7a_5b2bfd6a :
PS1, Line 530: event_timeout_init(&c->c2.scheduled_exit, n_seconds, now);
Quoted 1 line
It is always
c->options.scheduled_exit_intervalwhich is always 5 at the moment.
Done
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/555?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I9457f005f4ba970502e6b667d9dc4299a588d661
Gerrit-Change-Number: 555
Gerrit-PatchSet: 2
Gerrit-Owner: reynir <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-Reviewer: reynir <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: reynir <[email protected]...>
Gerrit-Comment-Date: Wed, 24 Apr 2024 12:13:13 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: flichtenheld <[email protected]...>
Comment-In-Reply-To: reynir <[email protected]...>
Gerrit-MessageType: comment
PATCH v2 1/1 Only schedule_exit() once
In reply to a message not in the archiveFrom: Reynir Björnsson <[email protected]...>
If an exit has already been scheduled we should not schedule it again. Otherwise, the exit signal is never emitted if the peer reschedules the exit before the timeout occurs.
schedule_exit() now only takes the context as argument. The signal is hard coded to SIGTERM, and the interval is read directly from the context options.
Furthermore, schedule_exit() now returns a bool signifying whether an exit was scheduled; false if exit is already scheduled. The call sites are updated accordingly. A notable difference is that management is only notified *once* when an exit is scheduled - we no longer notify management on redundant exit.
---
This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/555
This mail reflects revision 2 of this Change.
Acked-by according to Gerrit (reflected above):
Frank Lichtenheld <[email protected]...>
src/openvpn/forward.c +10 -4
@@ -514,17 +514,23 @@ }/* -* Schedule a signal n_seconds from now. +* Schedule a SIGTERM signal c->options.scheduled_exit_interval seconds from now. */ -void -schedule_exit (struct context *c,const int n_seconds,const int signal) +bool +schedule_exit (struct context *c) { +const int n_seconds = c->options.scheduled_exit_interval; +/* don't reschedule if already scheduled. */ +if (event_timeout_defined (&c->c2.scheduled_exit)) { +return false; + }tls_set_single_session (c->c2.tls_multi);update_time ();reset_coarse_timers (c);event_timeout_init (&c->c2.scheduled_exit, n_seconds, now); - c->c2.scheduled_exit_signal = signal; + c->c2.scheduled_exit_signal =SIGTERM ;msg (D_SCHED_EXIT ,"Delayed exit in %d seconds" , n_seconds); +return true; }/*
src/openvpn/forward.h +1 -1
@@ -303,7 +303,7 @@void process_ip_header (struct context *c,unsigned int flags,struct buffer *buf); -void schedule_exit (struct context *c,const int n_seconds,const int signal); +bool schedule_exit (struct context *c);static inline struct link_socket_info *get_link_socket_info (struct context *c)
src/openvpn/push.c +5 -6
@@ -191,6 +191,7 @@ receive_exit_message(struct context *c) {dmsg (D_STREAM_ERRORS ,"CC-EEN exit message received by peer" ); +bool notify_management = true;/* With control channel exit notification, we want to give the session * enough time to handle retransmits and acknowledgment, so that eventual * retries from the client to resend the exit or ACKs will not trigger
@@ -204,14 +205,14 @@* */ if (c->options.mode ==MODE_SERVER ) { -schedule_exit (c, c->options.scheduled_exit_interval,SIGTERM ); + notify_management =schedule_exit (c); }else {register_signal (c->sig,SIGUSR1 ,"remote-exit" ); }#ifdef ENABLE_MANAGEMENT -if (management) +if (management && notify_management) {management_notify (management,"info" ,"remote-exit" ,"EXIT" ); }
@@ -391,7 +392,7 @@void send_auth_failed (struct context *c,const char *client_reason) { -if (event_timeout_defined (&c->c2.scheduled_exit)) +if (!schedule_exit (c)) {msg (D_TLS_DEBUG ,"exit already scheduled for context" );return ;
@@ -401,8 +402,6 @@static const char auth_failed[] ="AUTH_FAILED" ;size_t len; -schedule_exit (c, c->options.scheduled_exit_interval,SIGTERM ); - len = (client_reason ?strlen (client_reason)+1 :0 ) +sizeof (auth_failed);if (len >PUSH_BUNDLE_SIZE ) {
@@ -492,7 +491,7 @@void send_restart (struct context *c,const char *kill_msg) { -schedule_exit (c, c->options.scheduled_exit_interval,SIGTERM ); +schedule_exit (c);send_control_channel_string (c, kill_msg ? kill_msg :"RESTART" ,D_PUSH ); }
Attention is currently required from: reynir.
plaisthos has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/555?usp=email )
Change subject: Only schedule_exit() once
......................................................................
Patch Set 2: Code-Review+2
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/555?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I9457f005f4ba970502e6b667d9dc4299a588d661
Gerrit-Change-Number: 555
Gerrit-PatchSet: 2
Gerrit-Owner: reynir <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-Reviewer: reynir <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: reynir <[email protected]...>
Gerrit-Comment-Date: Tue, 14 May 2024 13:15:58 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
Attention is currently required from: flichtenheld, plaisthos, reynir.
Hello flichtenheld, plaisthos,
I'd like you to reexamine a change. Please visit
http://gerrit.openvpn.net/c/openvpn/+/555?usp=email
to look at the new patch set (#3).
The following approvals got outdated and were removed:
Code-Review+2 by flichtenheld, Code-Review+2 by plaisthos
The change is no longer submittable: Code-Review and checks~ChecksSubmitRule are unsatisfied now.
Change subject: Only schedule_exit() once
......................................................................
Only schedule_exit() once
If an exit has already been scheduled we should not schedule it again. Otherwise, the exit signal is never emitted if the peer reschedules the exit before the timeout occurs.
schedule_exit() now only takes the context as argument. The signal is hard coded to SIGTERM, and the interval is read directly from the context options.
Furthermore, schedule_exit() now returns a bool signifying whether an exit was scheduled; false if exit is already scheduled. The call sites are updated accordingly. A notable difference is that management is only notified *once* when an exit is scheduled - we no longer notify management on redundant exit.
This patch was assigned a CVE number after already reviewed and ACKed, because it was discovered that a misbehaving client can use the (now fixed) server behaviour to avoid being disconnected by means of a managment interface "client-kill" command - the security issue here is "client can circumvent security policy set by management interface".
This only affects previously authenticated clients, and only management client-kill, so normal renegotion / AUTH_FAIL ("your session ends") is not affected.
CVE: 2024-28882
---
M src/openvpn/forward.c
M src/openvpn/forward.h
M src/openvpn/push.c
3 files changed, 19 insertions(+), 10 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/55/555/3
src/openvpn/forward.c +11 -4
@@ -514,17 +514,24 @@ }/* -* Schedule a signal n_seconds from now. +* Schedule a SIGTERM signal c->options.scheduled_exit_interval seconds from now. */ -void -schedule_exit (struct context *c,const int n_seconds,const int signal) +bool +schedule_exit (struct context *c) { +const int n_seconds = c->options.scheduled_exit_interval; +/* don't reschedule if already scheduled. */ +if (event_timeout_defined (&c->c2.scheduled_exit)) + { +return false; + }tls_set_single_session (c->c2.tls_multi);update_time ();reset_coarse_timers (c);event_timeout_init (&c->c2.scheduled_exit, n_seconds, now); - c->c2.scheduled_exit_signal = signal; + c->c2.scheduled_exit_signal =SIGTERM ;msg (D_SCHED_EXIT ,"Delayed exit in %d seconds" , n_seconds); +return true; }/*
src/openvpn/forward.h +1 -1
@@ -303,7 +303,7 @@void process_ip_header (struct context *c,unsigned int flags,struct buffer *buf); -void schedule_exit (struct context *c,const int n_seconds,const int signal); +bool schedule_exit (struct context *c);static inline struct link_socket_info *get_link_socket_info (struct context *c)
src/openvpn/push.c +7 -5
@@ -204,7 +204,11 @@* */ if (c->options.mode ==MODE_SERVER ) { -schedule_exit (c, c->options.scheduled_exit_interval,SIGTERM ); +if (!schedule_exit (c)) + { +/* Return early when we don't need to notify management */ +return ; + } }else {
@@ -391,7 +395,7 @@void send_auth_failed (struct context *c,const char *client_reason) { -if (event_timeout_defined (&c->c2.scheduled_exit)) +if (!schedule_exit (c)) {msg (D_TLS_DEBUG ,"exit already scheduled for context" );return ;
@@ -401,8 +405,6 @@static const char auth_failed[] ="AUTH_FAILED" ;size_t len; -schedule_exit (c, c->options.scheduled_exit_interval,SIGTERM ); - len = (client_reason ?strlen (client_reason)+1 :0 ) +sizeof (auth_failed);if (len >PUSH_BUNDLE_SIZE ) {
@@ -492,7 +494,7 @@void send_restart (struct context *c,const char *kill_msg) { -schedule_exit (c, c->options.scheduled_exit_interval,SIGTERM ); +schedule_exit (c);send_control_channel_string (c, kill_msg ? kill_msg :"RESTART" ,D_PUSH ); }
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/555?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I9457f005f4ba970502e6b667d9dc4299a588d661
Gerrit-Change-Number: 555
Gerrit-PatchSet: 3
Gerrit-Owner: reynir <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-Reviewer: reynir <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: reynir <[email protected]...>
Gerrit-MessageType: newpatchset
Attention is currently required from: flichtenheld, reynir.
plaisthos has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/555?usp=email )
Change subject: Only schedule_exit() once
......................................................................
Patch Set 3:
(1 comment)
File src/openvpn/forward.c:
http://gerrit.openvpn.net/c/openvpn/+/555/comment/e98ba825_8fe5fe4e :
PS1, Line 529: reset_coarse_timers(c);
Quoted 1 line
I am not sure what the above three function calls do and if we should still call them.
reset_coarse_timers ensures that newly scheduled timer actually is taken into account. update_time updates now for that. And tls_set_single_session in typical OpenVPN fashion ensure that no renegotion can happy by using a completely different feature of setting the session into a mode where no renegotiation can happen.
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/555?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I9457f005f4ba970502e6b667d9dc4299a588d661
Gerrit-Change-Number: 555
Gerrit-PatchSet: 3
Gerrit-Owner: reynir <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-Reviewer: reynir <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: reynir <[email protected]...>
Gerrit-Comment-Date: Thu, 16 May 2024 11:12:38 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: reynir <[email protected]...>
Gerrit-MessageType: comment
Attention is currently required from: flichtenheld, reynir.
plaisthos has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/555?usp=email )
Change subject: Only schedule_exit() once
......................................................................
Patch Set 3: Code-Review+2
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/555?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I9457f005f4ba970502e6b667d9dc4299a588d661
Gerrit-Change-Number: 555
Gerrit-PatchSet: 3
Gerrit-Owner: reynir <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-Reviewer: reynir <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: reynir <[email protected]...>
Gerrit-Comment-Date: Thu, 16 May 2024 11:13:23 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
PATCH v3 1/1 Only schedule_exit() once
In reply to a message not in the archiveFrom: Reynir Björnsson <[email protected]...>
If an exit has already been scheduled we should not schedule it again. Otherwise, the exit signal is never emitted if the peer reschedules the exit before the timeout occurs.
schedule_exit() now only takes the context as argument. The signal is hard coded to SIGTERM, and the interval is read directly from the context options.
Furthermore, schedule_exit() now returns a bool signifying whether an exit was scheduled; false if exit is already scheduled. The call sites are updated accordingly. A notable difference is that management is only notified *once* when an exit is scheduled - we no longer notify management on redundant exit.
This patch was assigned a CVE number after already reviewed and ACKed, because it was discovered that a misbehaving client can use the (now fixed) server behaviour to avoid being disconnected by means of a managment interface "client-kill" command - the security issue here is "client can circumvent security policy set by management interface".
This only affects previously authenticated clients, and only management client-kill, so normal renegotion / AUTH_FAIL ("your session ends") is not affected.
CVE: 2024-28882
---
This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/555
This mail reflects revision 3 of this Change.
Acked-by according to Gerrit (reflected above):
Arne Schwabe <[email protected]...>
src/openvpn/forward.c +11 -4
@@ -514,17 +514,24 @@ }/* -* Schedule a signal n_seconds from now. +* Schedule a SIGTERM signal c->options.scheduled_exit_interval seconds from now. */ -void -schedule_exit (struct context *c,const int n_seconds,const int signal) +bool +schedule_exit (struct context *c) { +const int n_seconds = c->options.scheduled_exit_interval; +/* don't reschedule if already scheduled. */ +if (event_timeout_defined (&c->c2.scheduled_exit)) + { +return false; + }tls_set_single_session (c->c2.tls_multi);update_time ();reset_coarse_timers (c);event_timeout_init (&c->c2.scheduled_exit, n_seconds, now); - c->c2.scheduled_exit_signal = signal; + c->c2.scheduled_exit_signal =SIGTERM ;msg (D_SCHED_EXIT ,"Delayed exit in %d seconds" , n_seconds); +return true; }/*
src/openvpn/forward.h +1 -1
@@ -303,7 +303,7 @@void process_ip_header (struct context *c,unsigned int flags,struct buffer *buf); -void schedule_exit (struct context *c,const int n_seconds,const int signal); +bool schedule_exit (struct context *c);static inline struct link_socket_info *get_link_socket_info (struct context *c)
src/openvpn/push.c +7 -5
@@ -204,7 +204,11 @@* */ if (c->options.mode ==MODE_SERVER ) { -schedule_exit (c, c->options.scheduled_exit_interval,SIGTERM ); +if (!schedule_exit (c)) + { +/* Return early when we don't need to notify management */ +return ; + } }else {
@@ -391,7 +395,7 @@void send_auth_failed (struct context *c,const char *client_reason) { -if (event_timeout_defined (&c->c2.scheduled_exit)) +if (!schedule_exit (c)) {msg (D_TLS_DEBUG ,"exit already scheduled for context" );return ;
@@ -401,8 +405,6 @@static const char auth_failed[] ="AUTH_FAILED" ;size_t len; -schedule_exit (c, c->options.scheduled_exit_interval,SIGTERM ); - len = (client_reason ?strlen (client_reason)+1 :0 ) +sizeof (auth_failed);if (len >PUSH_BUNDLE_SIZE ) {
@@ -492,7 +494,7 @@void send_restart (struct context *c,const char *kill_msg) { -schedule_exit (c, c->options.scheduled_exit_interval,SIGTERM ); +schedule_exit (c);send_control_channel_string (c, kill_msg ? kill_msg :"RESTART" ,D_PUSH ); }
[Openvpn-devel] [PATCH applied] Re: Only schedule_exit() once
Thanks :-) - this is mostly the same as v2, with a whitespace fix, and remodeling receive_exit_message() to avoid -Werror failures when comping without ENABLE_MANAGEMENT ("unused variable").
Tested on GHA, buildbots and the server testbed.
Your patch has been applied to the master and release/2.6 branch.
The CC EEN functionality is not part of 2.5, so the "clients can use this to get not dropped off" attack does not exist - and the patch is not applicable.
commit 55bb3260c12bae33b6a8eac73cbb6972f8517411 (master) commit 65fb67cd6c320a426567b2922c4282fb8738ba3f (release/2.6)
Author: Reynir Björnsson Date: Thu May 16 13:58:08 2024 +0200
Only schedule_exit() once
Signed-off-by: Reynir Björnsson <[email protected]...>
Acked-by: Arne Schwabe <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg28679.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
cron2 has uploaded a new patch set (#4) to the change originally created by reynir. ( http://gerrit.openvpn.net/c/openvpn/+/555?usp=email )
The following approvals got outdated and were removed:
Code-Review+2 by plaisthos
Change subject: Only schedule_exit() once
......................................................................
Only schedule_exit() once
If an exit has already been scheduled we should not schedule it again. Otherwise, the exit signal is never emitted if the peer reschedules the exit before the timeout occurs.
schedule_exit() now only takes the context as argument. The signal is hard coded to SIGTERM, and the interval is read directly from the context options.
Furthermore, schedule_exit() now returns a bool signifying whether an exit was scheduled; false if exit is already scheduled. The call sites are updated accordingly. A notable difference is that management is only notified *once* when an exit is scheduled - we no longer notify management on redundant exit.
This patch was assigned a CVE number after already reviewed and ACKed, because it was discovered that a misbehaving client can use the (now fixed) server behaviour to avoid being disconnected by means of a managment interface "client-kill" command - the security issue here is "client can circumvent security policy set by management interface".
This only affects previously authenticated clients, and only management client-kill, so normal renegotion / AUTH_FAIL ("your session ends") is not affected.
CVE: 2024-28882
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg28679.html
---
M src/openvpn/forward.c
M src/openvpn/forward.h
M src/openvpn/push.c
3 files changed, 19 insertions(+), 10 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/55/555/4
src/openvpn/forward.c +11 -4
@@ -514,17 +514,24 @@ }/* -* Schedule a signal n_seconds from now. +* Schedule a SIGTERM signal c->options.scheduled_exit_interval seconds from now. */ -void -schedule_exit (struct context *c,const int n_seconds,const int signal) +bool +schedule_exit (struct context *c) { +const int n_seconds = c->options.scheduled_exit_interval; +/* don't reschedule if already scheduled. */ +if (event_timeout_defined (&c->c2.scheduled_exit)) + { +return false; + }tls_set_single_session (c->c2.tls_multi);update_time ();reset_coarse_timers (c);event_timeout_init (&c->c2.scheduled_exit, n_seconds, now); - c->c2.scheduled_exit_signal = signal; + c->c2.scheduled_exit_signal =SIGTERM ;msg (D_SCHED_EXIT ,"Delayed exit in %d seconds" , n_seconds); +return true; }/*
src/openvpn/forward.h +1 -1
@@ -303,7 +303,7 @@void process_ip_header (struct context *c,unsigned int flags,struct buffer *buf); -void schedule_exit (struct context *c,const int n_seconds,const int signal); +bool schedule_exit (struct context *c);static inline struct link_socket_info *get_link_socket_info (struct context *c)
src/openvpn/push.c +7 -5
@@ -204,7 +204,11 @@* */ if (c->options.mode ==MODE_SERVER ) { -schedule_exit (c, c->options.scheduled_exit_interval,SIGTERM ); +if (!schedule_exit (c)) + { +/* Return early when we don't need to notify management */ +return ; + } }else {
@@ -391,7 +395,7 @@void send_auth_failed (struct context *c,const char *client_reason) { -if (event_timeout_defined (&c->c2.scheduled_exit)) +if (!schedule_exit (c)) {msg (D_TLS_DEBUG ,"exit already scheduled for context" );return ;
@@ -401,8 +405,6 @@static const char auth_failed[] ="AUTH_FAILED" ;size_t len; -schedule_exit (c, c->options.scheduled_exit_interval,SIGTERM ); - len = (client_reason ?strlen (client_reason)+1 :0 ) +sizeof (auth_failed);if (len >PUSH_BUNDLE_SIZE ) {
@@ -492,7 +494,7 @@void send_restart (struct context *c,const char *kill_msg) { -schedule_exit (c, c->options.scheduled_exit_interval,SIGTERM ); +schedule_exit (c);send_control_channel_string (c, kill_msg ? kill_msg :"RESTART" ,D_PUSH ); }
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/555?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I9457f005f4ba970502e6b667d9dc4299a588d661
Gerrit-Change-Number: 555
Gerrit-PatchSet: 4
Gerrit-Owner: reynir <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-Reviewer: reynir <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: newpatchset
cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/555?usp=email )
Change subject: Only schedule_exit() once
......................................................................
Only schedule_exit() once
If an exit has already been scheduled we should not schedule it again. Otherwise, the exit signal is never emitted if the peer reschedules the exit before the timeout occurs.
schedule_exit() now only takes the context as argument. The signal is hard coded to SIGTERM, and the interval is read directly from the context options.
Furthermore, schedule_exit() now returns a bool signifying whether an exit was scheduled; false if exit is already scheduled. The call sites are updated accordingly. A notable difference is that management is only notified *once* when an exit is scheduled - we no longer notify management on redundant exit.
This patch was assigned a CVE number after already reviewed and ACKed, because it was discovered that a misbehaving client can use the (now fixed) server behaviour to avoid being disconnected by means of a managment interface "client-kill" command - the security issue here is "client can circumvent security policy set by management interface".
This only affects previously authenticated clients, and only management client-kill, so normal renegotion / AUTH_FAIL ("your session ends") is not affected.
CVE: 2024-28882
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg28679.html
---
M src/openvpn/forward.c
M src/openvpn/forward.h
M src/openvpn/push.c
3 files changed, 19 insertions(+), 10 deletions(-)
src/openvpn/forward.c +11 -4
@@ -514,17 +514,24 @@ }/* -* Schedule a signal n_seconds from now. +* Schedule a SIGTERM signal c->options.scheduled_exit_interval seconds from now. */ -void -schedule_exit (struct context *c,const int n_seconds,const int signal) +bool +schedule_exit (struct context *c) { +const int n_seconds = c->options.scheduled_exit_interval; +/* don't reschedule if already scheduled. */ +if (event_timeout_defined (&c->c2.scheduled_exit)) + { +return false; + }tls_set_single_session (c->c2.tls_multi);update_time ();reset_coarse_timers (c);event_timeout_init (&c->c2.scheduled_exit, n_seconds, now); - c->c2.scheduled_exit_signal = signal; + c->c2.scheduled_exit_signal =SIGTERM ;msg (D_SCHED_EXIT ,"Delayed exit in %d seconds" , n_seconds); +return true; }/*
src/openvpn/forward.h +1 -1
@@ -303,7 +303,7 @@void process_ip_header (struct context *c,unsigned int flags,struct buffer *buf); -void schedule_exit (struct context *c,const int n_seconds,const int signal); +bool schedule_exit (struct context *c);static inline struct link_socket_info *get_link_socket_info (struct context *c)
src/openvpn/push.c +7 -5
@@ -204,7 +204,11 @@* */ if (c->options.mode ==MODE_SERVER ) { -schedule_exit (c, c->options.scheduled_exit_interval,SIGTERM ); +if (!schedule_exit (c)) + { +/* Return early when we don't need to notify management */ +return ; + } }else {
@@ -391,7 +395,7 @@void send_auth_failed (struct context *c,const char *client_reason) { -if (event_timeout_defined (&c->c2.scheduled_exit)) +if (!schedule_exit (c)) {msg (D_TLS_DEBUG ,"exit already scheduled for context" );return ;
@@ -401,8 +405,6 @@static const char auth_failed[] ="AUTH_FAILED" ;size_t len; -schedule_exit (c, c->options.scheduled_exit_interval,SIGTERM ); - len = (client_reason ?strlen (client_reason)+1 :0 ) +sizeof (auth_failed);if (len >PUSH_BUNDLE_SIZE ) {
@@ -492,7 +494,7 @@void send_restart (struct context *c,const char *kill_msg) { -schedule_exit (c, c->options.scheduled_exit_interval,SIGTERM ); +schedule_exit (c);send_control_channel_string (c, kill_msg ? kill_msg :"RESTART" ,D_PUSH ); }
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/555?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I9457f005f4ba970502e6b667d9dc4299a588d661
Gerrit-Change-Number: 555
Gerrit-PatchSet: 4
Gerrit-Owner: reynir <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-Reviewer: reynir <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: merged